<?php
/**
 * [PHPFOX_HEADER]
 */

defined('PHPFOX') or exit('NO DICE!');

/**
 * 
 * 
 * @copyright		[PHPFOX_COPYRIGHT]
 * @author  		Miguel Espinoza (Purefan)
 * @package 		Phpfox_Ajax
 * @version 		$Id: ajax.class.php 100 2009-01-26 15:15:26Z Raymond_Benc $
 */
class Iaip1_Component_Ajax_Ajax extends Phpfox_Ajax
{
	
	/**
	 * Gets the number of days and returns the users who have not logged in within that number of days 
	 */
	function fetchUsers()
	{
		$iDays = (int)$this->get('iDays');
		Phpfox::getBlock('iaip1.fetchedUsers', array('iDays' => $iDays));		
		$this->html('#iaiSearchResults', $this->getContent(false));
		$this->show('#iaiSearchResults');
		$this->hide('#iaiSearching');
	}
	
	/*
	 * Coordinates the deletion of users
	 * */
	function deleteUsers()
	{
		Phpfox::isAdmin(true);
		$sUsers = $this->get('aUsers');
		$bDelete = Phpfox::getService('iaip1.process')->deleteUsers($sUsers);
		if ($bDelete == true)
		{
			$this->hide('#iaiSearchResults');
			$this->alert(Phpfox::getPhrase('iaip1.the_users_you_selected_have_been_deleted_succesfully'));
		}
		else
		{
			// error is handled by Phpfox_Error
		}
	}
}

?>
